package com.ldu.houserent.controller.front;

import com.ldu.houserent.common.base.BaseController;
import com.ldu.houserent.common.constant.Constant;
import com.ldu.houserent.common.enums.HouseRentTypeEnum;
import com.ldu.houserent.service.HouseService;
import com.ldu.houserent.service.OrderService;
import com.ldu.houserent.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/*
    前端首页控制器
 */
@Controller
public class IndexController extends BaseController {

    @Autowired
    private OrderService orderService;
    @Autowired
    private HouseService houseService;
    @Autowired
    private UserService userService;

    /**
     * 前端首页
     */
    @RequestMapping("/")
    public String index(Model model){
        //最新整租，将查询到的结果放到model中，在jsp页面用EL表达式获取
        model.addAttribute("rencentWholeHouseList",
                houseService.findTopList(HouseRentTypeEnum.WHOLE.getValue(), Constant.INDEX_HOUSE_NUM));    //整租，每页6条
        //最新合租，将查询到的结果放到model中
        model.addAttribute("rencentShareHouseList",
                houseService.findTopList(HouseRentTypeEnum.SHARE.getValue(), Constant.INDEX_HOUSE_NUM));

        return "front/index";
    }


}
